#!/bin/sh

echo "build zt-mock-admin services..."
docker build --no-cache=true \
    --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
    --build-arg BUILD_VERSION="1.0.0" \
    -t zt-mock-admin:1.0.0 .

IPA_SERVER_IP=`docker inspect zt-mock-server --format='{{.NetworkSettings.IPAddress}}'`

echo "start zt-mock-admin service..."
docker run -d \
    -p 8080:80 \
    --name zt-mock-admin \
    --hostname zt-mock-admin \
    --restart always \
    --add-host zt-mock-server:$IPA_SERVER_IP \
    zt-mock-admin:1.0.0
echo "waiting for zt-mock-admin initialization..."
sleep 2s
docker logs --tail=10 zt-mock-admin